package com.gzsxy.esjy.configuration.properties;

import com.gzsxy.esjy.SvConstant;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * 服务配置
 * @author zhangxiaolong
 * @date 2022/7/6 9:36
 */
@Configuration
public class ServerProperties {

	/**
	 * 服务端口
	 */
    @Value("${server.port:9001}")
    private int port;
    
    /**
     * 是否保持连接
     */
    @Value("${server.http.keep_live:true}")
    private boolean keepLive ;

    /**
     * boss线程数
     */
    @Value("${server.thread.boss:1}")
    private int bossThread ;
 
    
    /**
     * worker线程数
     */
    @Value("${server.thread.worker:16}")
    private int workerThread ;
    
    /**
     * 业务线程池：最大
     */
	@Value("${server.thread.pool.max:3000}")
	private int maxmumPoolSize ;
	
	/**
	 * 业务线程池：核心
	 */
	@Value("${server.thread.pool.core:20}")
	private int coremumPoolSize ;
	
	/**
	 * 业务线程池：存活
	 */
	@Value("${server.thread.pool.live:60}")
	private int live ;
	
	/**
	 * http服务启用业务线程
	 */
	@Value("${server.thread.pool.normal.enabled:true}")
	private boolean normalEnabled ;
	
	/**
	 * http服务启用业务线程
	 */
	@Value("#{${server.http.request.body.max:10240}*1024}")
	private long bodyMax ;
	
	@PostConstruct
	private void init() {
		SvConstant.MAX_LENGTH = bodyMax ;
		SvConstant.KEEP_LIVE = keepLive ;
	}


	public boolean isNormalEnabled() {
		return normalEnabled;
	}

	public int getBossThread() {
		return bossThread;
	}

	public int getWorkerThread() {
		return workerThread;
	}

	public int getPort() {
		return port;
	}

	public int getMaxmumPoolSize() {
		return maxmumPoolSize;
	}

	public int getCoremumPoolSize() {
		return coremumPoolSize;
	}

	public int getLive() {
		return live;
	}

	public boolean isKeepLive() {
		return keepLive;
	}
    
    
    
}
